Text to Speech with Liberty BASIC

Using a Third Party DLL to Communicate with Microsoft Agent

by Stefan Pendl

megabit@t-online.at


Home

Text To Speech - Pendl

Novice Puzzles - Terra

Slider Controls - Bradbury

Symmetrical Paint - Nally

Programming Style - Brossman

Progress Simulator - Rahman

CD Menus - Sweet

Media File Search - Sweet

Why Liberty BASIC? - Sweet

Submission Guildlines

Newsletter Help

Index

The History of My Text-To-Speech Project

This project was started by accident. I was searching for a manual for the NviewLib.dll. At the same time Gordon Sweet asked me for support to use the narrator.exe coming with Win2k and WinXP for Text to Speech output.

I finaly found a helpfile for the NviewLib.dll and a Speech.dll at the same site.

In the package for the Speech.dll were some samples written in RapidQ BASIC. I translated one of them to Text2Speech_medium.bas. The minimum requirements are shown by Text2Speech_short.bas. All you can do with this dll regarding Text to Speech is shown by Text2Speech_delux.bas.

Some features: change speed, pitch and volume during speech replay and use text from the clipboard.

Files Included in the Text-To-Speech Archive

The file included in the archive are as follows:

Helpful Web Resources for Text-To-Speech

The following Text-to-Speech web resources may be helpful:

Testing the Readiness of Your System for Text-To-Speech

The following sample will check if you are ready to speek ;-))

Have fun using TTS !!!

' -------------------------------------------------------------------------
' Text to Speech using MS Agent
' 
' and
' 
'
' based on tts_tool.c by Martin Goebel
' 
'
' using stm.dll and ttw.dll by John White
' 
'
' by Stefan Pendl 
'
' Revision History
' ================
'
' Version | Date        | Name         | Reason
' --------|-------------|--------------|-----------------------------------
'  1.0    | 30.Jan.2004 | Stefan Pendl | Initial

    nomainwin

'constants:
    TEXT.BUFFER.SIZE = 5000

'variables to preset:
    voiceTotal = 0

'at the very beginning of your app to check if speech is installed:
    open "stm.dll" for dll as #speech
    speechOpen = 1

    rtn = BeginSpeech(TEXT.BUFFER.SIZE)
    if rtn = 1 then
        voiceTotal = CountVoices()
        if voiceTotal > 0 then
            notice "Congratulations";chr$(13);_
                   "You are ready for Text to Speech."
            goto [quit]
        else
            notice "Speech API 4 Error";chr$(13);_
                   "Speech API 4 Runtime and/or Voice Engines NOT Installed."
            goto [quit]
        end if
    else
        notice "Speech Library Error";chr$(13);_
               "MS Agent Core NOT Installed."
        goto [quit]
    end if

'before ending your app:
[quit]
    if speechOpen = 1 then
        rtn = EndSpeech()
        close #speech
    end if
END


'functions and subs:
function BeginSpeech(BufferSize)
    calldll #speech, "Begin_Speech",_
        BufferSize  as long,_    ' memory buffer size in bytes; >= 5000
        BeginSpeech as long      ' 1 ... success; 0 ... error
end function

function EndSpeech()
    calldll #speech, "End_Speech",_
        EndSpeech as long
end function

function CountVoices()
    calldll #speech, "Count_Voices",_
        CountVoices as long      ' 0 if no voices are installed
end function                     '  else the number of installed voices


Home

Text To Speech - Pendl

Novice Puzzles - Terra

Slider Controls - Bradbury

Symmetrical Paint - Nally

Programming Style - Brossman

Progress Simulator - Rahman

CD Menus - Sweet

Media File Search - Sweet

Why Liberty BASIC? - Sweet

Submission Guildlines

Newsletter Help

Index